Copy file url to clipboard

James Peret 8 years ago
parent
commit
e28ca5af4c

+ 6 - 0
app/scripts/controllers/app-ctrl.js

@@ -116,6 +116,7 @@ angular.module('codexApp.index', [])
116 116
     var Menu = remote.require('menu');
117 117
     var MenuItem = remote.require('menu-item');
118 118
     var currentWindow = remote.getCurrentWindow();
119
+    var clipboard = require('clipboard');
119 120
 
120 121
     $scope.fileContextMenu = function (file) {
121 122
       var menu = new Menu();
@@ -125,6 +126,11 @@ angular.module('codexApp.index', [])
125 126
       menu.append(new MenuItem({ label: 'Edit File', click: function () {
126 127
         $scope.editFile(file);
127 128
       } }));
129
+      menu.append(new MenuItem({ label: 'Copy File URL', click: function () {
130
+        var url = file.path;
131
+        console.log("-> Copying URL to clipboard " + url);
132
+        clipboard.writeText(url);
133
+      } }));
128 134
       menu.popup(currentWindow);
129 135
     }
130 136
   }]);

+ 2 - 7
app/scripts/controllers/note-view-ctrl.js

@@ -64,18 +64,13 @@ angular.module('codexApp.noteView', [])
64 64
               open(e.srcElement.outerHTML.match(/href="([^"]*)/)[1]);
65 65
             }
66 66
             if(e.srcElement.protocol == "file:"){
67
-              var current_note = FileService.getCurrentNote().path;
68
-              var relative_path = e.srcElement.outerHTML.match(/href="([^"]*)/)[1];
69
-              var fixed_url = $scope.fixRelativeURL(current_note, relative_path);
70
-
71
-              var note = FileService.getNote(fixed_url);
67
+              var url = e.srcElement.outerHTML.match(/href="([^"]*)/)[1];
68
+              var note = FileService.getNote(url);
72 69
               FileService.setCurrentNote(note);
73 70
               $scope.note = note;
74 71
               console.log("-> Opening Link: " + note.path)
75 72
               $scope.loadNoteView();
76 73
             }
77
-
78
-
79 74
         }
80 75
         function updateContent() {
81 76
             // Do something with `this.responseText`

+ 2 - 2
app/scripts/services/file-service.js

@@ -297,7 +297,7 @@ angular.module('codexApp')
297 297
       root_path_count = root_path_count + 1;
298 298
     }
299 299
     var count = current_path_count - root_path_count;
300
-    console.log(current_path_count + " - " + root_path_count + " = " + count);
300
+    //console.log(current_path_count + " - " + root_path_count + " = " + count);
301 301
 
302 302
     //dif = current_path_count - (absolute_path_count -1);
303 303
     for (var i = 0; i < count; i++) {
@@ -305,7 +305,7 @@ angular.module('codexApp')
305 305
     }
306 306
     // make the relative path a string again
307 307
     var relative_path = absolute_path.join('/');
308
-    console.log("* Converted relative URL: " + relative_path)
308
+    //console.log("* Converted relative URL: " + relative_path)
309 309
     return relative_path;
310 310
   }
311 311
 

+ 19 - 5
codex/inbox/test_note.md

@@ -17,10 +17,8 @@ This is a quick review of the markdown syntax.
17 17
 #### H4
18 18
 ##### H5
19 19
 ```
20
-    
21
-## Lists
22 20
 
23
-#### Unordered List
21
+## Unordered List
24 22
 
25 23
 * Unordered list item 1
26 24
 * Unordered list item 2
@@ -32,7 +30,7 @@ This is a quick review of the markdown syntax.
32 30
 * Unordered list item 3
33 31
 ```
34 32
 
35
-#### Ordered List
33
+## Ordered List
36 34
 
37 35
 1. Ordered list item
38 36
 2. Ordered list item
@@ -56,4 +54,20 @@ This is a code block
56 54
 
57 55
 | header 1  | header 2  | header 3  |
58 56
 |-----------|-----------|-----------|
59
-| content 1 | content 2 | content 3 |
57
+| content 1 | content 2 | content 3 |
58
+| content 4 | content 5 | content 6 |
59
+
60
+```
61
+| header 1  | header 2  | header 3  |
62
+|-----------|-----------|-----------|
63
+| content 1 | content 2 | content 3 |
64
+| content 4 | content 5 | content 6 |
65
+```
66
+
67
+## Line Break
68
+
69
+---
70
+
71
+```
72
+---
73
+```